package com.example.lx6_2.order

import androidx.lifecycle.MutableLiveData
import com.example.base.entity.AddOrderParam
import com.example.base.entity.OrderEntity
import com.example.base.entity.OrderEntityItem
import com.example.base.mvvm.BaseViewModel
import com.example.base.net.ApiService
import dagger.hilt.android.lifecycle.HiltViewModel
import retrofit2.http.Body
import javax.inject.Inject

@HiltViewModel
class OrderViewModel @Inject constructor(val apiService: ApiService) : BaseViewModel() {

    val orderData = MutableLiveData<OrderEntity>()

    fun getOrder(){
        httpRequest({apiService.getOrder()},orderData::postValue)
    }

    val addOrderData = MutableLiveData<OrderEntityItem>()

    fun getAddOrder(body: Any){
        httpRequest({apiService.getAdd(toBody(body))},addOrderData::postValue)
    }

    val deleteOrderData = MutableLiveData<Boolean>()

    fun getDeleteOrder(id:Int){
        httpRequest({apiService.getDelete(id)},deleteOrderData::postValue)
    }

}